﻿namespace RotatingWalkInMatrix
{
    using System;
    using System.Text;

    public class Matrix 
    {
        private int length;
        private int[,] matrixArray;

        public Matrix(int length)
        {
            this.Length = length;
            this.matrixArray = new int[this.Length, this.Length];
        }

        public int Length
        {
            get 
            { 
                return this.length; 
            }
            set 
            {
                if (value < 1 || value > 100)
                {
                    throw new ArgumentOutOfRangeException("Invalid value of Matrix Length->The value must be in range 1<=n<=100 ");
                }

                this.length = value; 
            }
        }

        public int[,] MatrixArray
        {
            get 
            {
                return this.matrixArray;
            }
            private set 
            { 
            }
        }

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < this.MatrixArray.GetLength(0); i++)
            {
                for (int j = 0; j < this.MatrixArray.GetLength(1); j++)
                {
                    sb.Append(this.MatrixArray[i, j]);
                    sb.Append(" ");
                }
                sb.Append("\r\n");
            }

            return sb.ToString();
        }

    
    }
}
